@SuppressWarnings("unchecked")
public class p1015_timeout {

	public static//
	// -----
	// -----
	class Main {
		public static void main(String[] args) throws Exception {
			java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
			int id = 0;
			while (true) {
				String line = reader.readLine();
				if (line.isEmpty())
					continue;
				if (line.startsWith("0 0"))
					break;
				String[] parts = line.split(" ");
				int n = Integer.parseInt(parts[0]);
				int m = Integer.parseInt(parts[1]);
				int[][] data = read(reader, n);
				int[] juries = process(n, m, data);
				System.gc();

				int sump = 0, sumd = 0;
				for (int i : juries) {
					sump += data[i][0];
					sumd += data[i][1];
				}

				System.out.print("Jury #" + (++id) + "\nBest jury has value " + sump + " for prosecution and value "
						+ sumd + " for defence:\n");
				for (int i : juries)
					System.out.print(" " + (i + 1));
				System.out.print("\n\n");
			}
		}

		static int[][] read(java.io.BufferedReader reader, int n) throws Exception {
			int[][] data = new int[n][];
			for (int i = 0; i < n; i++) {
				String[] parts1 = reader.readLine().trim().split("\\s+");
				int pi = Integer.parseInt(parts1[0]);
				int di = Integer.parseInt(parts1[1]);
				data[i] = new int[] { pi, di, pi - di, pi + di };
			}
			return data;
		}

		static int[] process(int n, int m, int[][] data) {
			// m*n: dif->sum,last
			java.util.Map<Integer, int[]>[][] rounds = new java.util.Map[m][];

			// round 0
			java.util.Map<Integer, int[]>[] round = new java.util.Map[n];
			for (int i = 0; i <= n - m; i++) {
				int iabs = data[i][2], isum = data[i][3];
				java.util.Map<Integer, int[]> cell = new java.util.HashMap<Integer, int[]>();
				cell.put(iabs, new int[] { isum, 0 });
				round[i] = cell;
			}
			rounds[0] = round;
			java.util.Map<Integer, int[]>[] lround = round;
			// round x
			for (int roundId = 1; roundId < m; roundId++) {
				round = new java.util.Map[n];
				for (int i = roundId; i <= n - m + roundId; i++) {
					int idif = data[i][2], isum = data[i][3];
					java.util.Map<Integer, int[]> cell = new java.util.HashMap<Integer, int[]>();
					for (int li = roundId - 1; li < i; li++) {
						for (java.util.Map.Entry<Integer, int[]> entry : lround[li].entrySet()) {
							int dif = entry.getKey() + idif;
							int sum = entry.getValue()[0] + isum;

							int[] row = cell.get(dif);
							if (row == null)
								cell.put(dif, new int[] { sum, li });
							else if (row[0] < sum) {
								row[0] = sum;
								row[1] = li;
							}
						}
					}
					round[i] = cell;
				}
				rounds[roundId] = round;
				lround = round;
			}
			// reduce
			int minAbs = Integer.MAX_VALUE;
			int dif = Integer.MAX_VALUE;
			int maxSum = -1;
			int lasti = 0;
			for (int i = m - 1; i < n; i++) {
				for (java.util.Map.Entry<Integer, int[]> entry : lround[i].entrySet()) {
					int abs = Math.abs(entry.getKey());
					if (minAbs > abs) {
						minAbs = abs;
						dif = entry.getKey();
						maxSum = entry.getValue()[0];
						lasti = i;
					} else if (minAbs == abs) {
						int sum = entry.getValue()[0];
						if (sum > maxSum) {
							dif = entry.getKey();
							maxSum = sum;
							lasti = i;
						}
					}
				}
			}
			// output
			int[] juries = new int[m];
			juries[m - 1] = lasti;
			for (int i = m - 1; i > 0; i--) {
				juries[i - 1] = rounds[i][juries[i]].get(dif)[1];
				dif -= data[juries[i]][2];
			}
			return juries;
		}
	}

	// -----
	// -----

	public static void main(String[] args) throws Exception {
		Judge.run();
	}

}
